package com.ywb.ex08.controller;


import com.ywb.ex08.util.ConnectDB;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class AddData {

    public void operation() {
        Connection conn = ConnectDB.getConnection();
        try{
            String sql = "insert into tb_users (username,password,sex,age) values('李四','111','男','22')";
            Statement st = conn.createStatement();
            int result = st.executeUpdate(sql);
            if(result > 0) {
                System.out.println("添加成功");
            }
            st.close();
            conn.close();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
